package com.xcm.service.impl;

import com.google.common.collect.Lists;
import com.xcm.dao.ProgramTopMapper;
import com.xcm.model.TbProgramTop;
import com.xcm.model.dto.TopProgramDTO;
import com.xcm.service.ProgramTopService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 上屏节目Service实现类
 */
@Service(value = "programTopService")
public class ProgramTopServiceImpl implements ProgramTopService {
	@Autowired
	private ProgramTopMapper programTopMapper;

	/**
	 * 批量保存上屏节目
	 *
	 * @param programTopList List<TbProgramJson>类型对象
	 */
	@Override
	@Transactional(readOnly = false, rollbackFor = Exception.class)
	public void saveProgramTopBatch(List<TbProgramTop> programTopList) {
		programTopMapper.saveProgramTopBatch(programTopList);
	}

	/**
	 * 通过xc版本查找上屏屏节目列表
	 *
	 * @param xcVersion xc版本
	 * @return
	 */
	@Override
	public List<TbProgramTop> listProgramTopByXcVersion(String xcVersion, String top) {
		return programTopMapper.listProgramTopByXcVersion(xcVersion, top);
	}

	/**
	 * 通过xc版本获取上屏节目DTO列表
	 *
	 * @param xcVersion xc版本
	 * @return List<TopProgramDTO>
	 */
	@Override
	public List<TopProgramDTO> listTopProgramDTOByXcVersion(String xcVersion) {
		if (StringUtils.isBlank(xcVersion)) {
			return Lists.newArrayList();
		}
		return programTopMapper.listTopProgramDTOByXcVersion(xcVersion);
	}
}
